<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body {
            /*background-image: url("");*/
            background-size: cover; /*把背景图片设置为封面*/
            background-repeat: no-repeat;
            text-align: center;
        }

        h1 {
            font-size: 72px;
            color: #0096dc;
            margin-bottom: 0;
        }

        img {
            width: 100px
        }

        h2 {
            font-size: 32px;
            color: #0096dc;
            margin-bottom: 0;
        }

    </style>
</head>
<body>
<div id="app">
    <h1>欢迎来到考试管理系统</h1>
    <img src="">

    <el-card style="width: 600px;height: 400px;
    background-color: rgba(255,255,255,0.3);margin: 0 auto">
        <el-form label-width="60px" style="width: 400px;margin: 50px auto">
            <el-form-item label="昵称">
                <el-input type="text" v-model="user.nickname" placeholder="请输入昵称"></el-input>
            </el-form-item>
            <el-form-item label="用户">
                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" @keydown.native.enter="login()" v-model="user.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-form-item label="选择角色">
                <template>
                    <el-radio-group v-model="user.role">
                        <el-radio :label="0">管理员</el-radio>
                        <el-radio :label="1">教师</el-radio>
                        <el-radio :label="2">学生</el-radio>
                    </el-radio-group>
                </template>
            </el-form-item>
            <el-form-item>
                <el-button style="position: relative;left: -30px" type="primary" @click="reg()">注册</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                user: {nickname:"",username: "", password: "",role :""}
            }
        },
        methods: {
            login() {
                location.href="./login.html"
            },
            reg() {
                axios.post("/reg", v.user).then(function (response) {
                    location.href = "./login.html"
                    console.log(response)
                });
            }
        }

    })
</script>
</html>